<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Dbmanager extends CI_Controller {

        // 创建表
        public function createTable()
        {
            // 加载数据库工厂类
            $this->load->dbforge();

            $fields = array(
                'id'   =>  array(
                    'type'              =>  'INT',
                    'constraint'        =>  11,
                    'unsigned'          =>  TRUE,
                    'auto_increment'    =>  TRUE
                ),
                'pid'    =>  array(
                    'type'              =>  'INT',
                    'unsigned'          =>  TRUE
                ),
                'content'    =>  array(
                    'type'              =>  'TEXT'
                ),
                'writetime'    =>  array(
                    'type'              =>  'DATETIME'
                )
            );

            // 添加字段
            $this->dbforge->add_field($fields);

            // 添加主键
            $this->dbforge->add_key('id', TRUE);

            // 设置其它属性
            $attributes = array('ENGINE' => 'MyISAM');

            // 创建表
            $this->dbforge->create_table('progress', TRUE, $attributes);


            /* 项目表
            $fields = array(
                'id'   =>  array(
                    'type'              =>  'INT',
                    'constraint'        =>  11,
                    'unsigned'          =>  TRUE,
                    'auto_increment'    =>  TRUE
                ),
                'proname'    =>  array(
                    'type'              =>  'VARCHAR',
                    'constraint'        =>  100
                ),
                'starttime'    =>  array(
                    'type'              =>  'DATETIME'
                ),
                'status'    =>  array(
                    'type'              =>  'INT',
                    'constraint'        =>  11,
                    'default'        =>  1
                )
            );*/


            
             /* 用户表   
             $fields = array(
                'id'   =>  array(
                    'type'              =>  'INT',
                    'constraint'        =>  11,
                    'unsigned'          =>  TRUE,
                    'auto_increment'    =>  TRUE
                ),
                'username'    =>  array(
                    'type'              =>  'VARCHAR',
                    'constraint'        =>  20
                ),
                'password'    =>  array(
                    'type'              =>  'CHAR',
                    'constraint'        =>  32
                ),
                'email'    =>  array(
                    'type'              =>  'VARCHAR',
                    'constraint'        =>  50
                )
            );*/

          }
    }
